<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="author" content="Wangrui">
    <title></title>
    <style>
        .outer{
            width: 500px;
            margin: 0 auto;
            text-align: center;
        }
        .inner{
            width: 100px;
            height: 100px;
            background-color: lightseagreen;
            margin: 20px auto;
        }
    </style>
</head>
<body>
    <div class="outer">
        <input type="button" value="变宽">
        <input type="button" value="变高">
        <input type="button" value="变色">
        <input type="button" value="隐藏">
        <input type="button" value="重置">
        <div class="inner"></div>
    </div>
</body>
</html>
<script>
    
    var buttons = document.querySelectorAll('input');
    var div = document.querySelector('.inner');
    var attrs = ['width','height','backgroundColor','display','display'];
    var values = ['200px','200px','pink','none','block'];

    for(var i = 0; i < buttons.length; i++){
        buttons[i].index = i;
        buttons[i].onclick = function(){

            div.style[attrs[this.index]] = values[this.index];
            // div.style['width'] = '200px';
            
            if(this.index == buttons.length-1){
                // 当点击重置按钮时，将div的行内样式清空
                div.style.cssText = '';
            }
        }
    }
</script>